package com.fy56.platform.logistics.service.impl;

import com.fy56.platform.logistics.common.ResultModel;
import com.fy56.platform.logistics.common.ResultStatus;
import com.fy56.platform.logistics.mapper.UserMapper;
import com.fy56.platform.logistics.model.User;
import com.fy56.platform.logistics.service.web.IUserService;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author li
 * @date 2018-02-08 9:18
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public ResultModel exists(User var1){
        return null;
    }

    @Override
    @Transactional(readOnly = true)
    public ResultModel batchDelete(String[] var1){
        return null;
    }

    @Override
    public User getUserByLoginName(String var1){
        return null;
    }

    @Override
    public User getFirstUserByCompanyId(Integer var1){
        return null;
    }

    @Override
    public User selectByPrimaryKey(Long id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public User get(User entity) {
        return userMapper.get(entity);
    }

    @Override
    @Transactional(readOnly = false)
    public ResultModel insert(User entity) {
        ResultModel result = null;
        int r = userMapper.insert(entity);
        if(r == 0) {
            result = ResultModel.error(ResultStatus.INSERT_ERR);
        }else {
            result = ResultModel.ok();
        }
        return result;
    }

    @Override
    public ResultModel insertSelective(User entity) {
        return null;
    }

    @Override
    public ResultModel update(User entity) {
        ResultModel result = null;
        int r = userMapper.updateLogin(entity);
        if(r == 0) {
            result = ResultModel.error(ResultStatus.EDIT_ERR);
        }else {
            result = ResultModel.ok();
        }
        return result;
    }

    @Override
    public ResultModel updateSelective(User entity) {
        return null;
    }

    @Override
    public ResultModel delete(Long id) {
        return null;
    }


    @Override
    public ResultModel delete(User entity) {
        return null;
    }

    @Override
    public List<User> findList(User user) {
        return null;
    }





}
